<?php
	
	
function money($number)
{
	if(is_numeric($number))
	{
		return number_format($number, 2, '.',',');
	}else{
		return number_format(intval($number), 2, '.',',');
	}
}

if(!function_exists('arrayToObject'))
{
	function arrayToObject($d)
	{
		if (is_array($d)) {
			/*
			* Return array converted to object
			* Using __FUNCTION__ (Magic constant)
			* for recursive call
			*/
			return (object) array_map(__FUNCTION__, $d);
		}else{
			// Return object
			return $d;
		}
	}
}

/**
 * Check Profiles value is equal to parent_profile_updates
 * @param varchar $hash Contains Enrollment ID and Request ID
 * @param varchar	$field Table Column 
 * @param varchar $value Value to compare 
 */
	function check_profile_value($hash, $field, $value){

		$CI =& get_instance();
		$CI->load->library('hs');
		$x = $CI->hs->decrypt($hash);
		$CI->load->model('M_parent_profile_updates','m_ppu');

		if($x){
			$eid = $x[0];
			$rid = $x[1];

			$p = $CI->m_ppu->pull($rid, 'status');

			if($p && $p->status=="PENDING"){

				$rs = $CI->m_ppu->check_if_value_updated($x, $field, $value);

				if($rs){
					return "value_was_updated";
				}
			}
			
		}

		return "";
	}